<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<script type="text/javascript">
	function cli() {
		//confirm方法弹出一个对话框,可以选择确定与取消操作
		//同时该方法有返回值,true和false,两个布尔值
        return confirm("此表字段有子表，删除需先确认子表是否已删除，确认请继续");
	}
</script>

<body>
	<div class="content right">
		<!--主体-->
		<!--地区管理<>-->
		<c:if test="${param.sort==1||empty  param.sort}">
			<div class="row">
				<div class="col-md-3">
					<table border="1px" class="table table-hover">
						<th id="quyu">地区管理</th>
						<tr>
							<td>地区</td>
							<td><a href="edit?sort=1">添加地区</a></td>
						</tr>

						<c:forEach items="${districts}" var="d">
							<tr>
								<td>${d.name}</td>
								<td><a href="edit?sort=1&id=${d.id}">编辑</a></td>
								<td><a id="quyu-delete"    href="delete?sort=1&id=${d.id}"  onclick="return cli()">删除</a></td>
							</tr>
						</c:forEach>

					</table>
				</div>
			</div>
		<div class="qingli" style="width:100%;height:100px;"></div>
		</c:if>
		
		<!--街道管理<>-->
		<c:if test="${param.sort==2||empty  param.sort}">
			<div class="row ">
				<div class="col-md-3 ">
					<table border="1px " class="table table-condensed ">
						<th id="jiedao">街道管理</th>
						<tr>
							<td>街道</td>
							<td>所属区域</td>
							<td><a href="edit?sort=2">添加街道</a></td>
						</tr>

						<c:forEach items="${streets}" var="s">
							<tr>
								<td>${s.name}</td>
								<c:forEach items="${districts}" var="dis">
									<c:if test="${s.districtId==dis.id}">
										<td>${dis.name}</td>
									</c:if>
								</c:forEach>
								<td><a href="edit?sort=2&id=${s.id}">编辑</a></td>
								<td><a href="delete?sort=2&id=${s.id}"  onclick="return cli()">删除</a></td>
							</tr>
						</c:forEach>
					</table>
				</div>
			</div>
			
			 <div class="qingli" style="width:100%;height:100px;"></div>
		</c:if>
		<!--街道管理</>-->
		
		<!--房型管理<>-->
		<c:if test="${param.sort==3||empty  param.sort}">
			<div class="row ">
				<div class="col-md-3 ">
					<table border="1px " class="table table-condensed ">
						<th id="fangxing">房型管理</th>
						<tr>
							<td>房型</td>
							<td><a href="edit?sort=3">添加房型</a></td>
						</tr>
						<c:forEach items="${types}" var="t">
							<tr>
								<td>${t.name}</td>
								<td><a href="edit?sort=3&id=${t.id}">编辑</a></td>
								<td><a href="delete?sort=3&id=${t.id}">删除</a></td>
							</tr>
						</c:forEach>
					</table>
				</div>
			</div>
			  <div class="qingli" style="width:100%;height:100px;"></div>
		</c:if>
		<!--房型管理</>-->
		
		<!--用户管理 -->
		<c:if test="${param.sort==4||empty  param.sort}">	
		<div  class="row ">
			<div class="col-md-8 ">
				<table border="1px " class="table table-hover ">
					<th id="yonghu">用户管理</th>
					<tr>
						<td>序号</td>
						<td>用户名</td>
						<td>姓名</td>
						<td>电话</td>
						<td>邮箱</td>
						<td>账号状态</td>
						<td>操作</td>			
					</tr>
				 	<c:forEach items="${users}" var="u" varStatus="status">
					<tr>				
						<td>${status.index + 1}</td>
						<td>${u.username}</td>
						<td>${u.name}</td>
						<td>${u.phone}</td>
						<td>${u.email}</td>	
						<td>
						<c:if test="${u.isInUse==false}">正常</c:if>	
						<c:if test="${u.isInUse==true}">已停用</c:if>										
						</td>	
						<td><a href="update?isInUse=1&id=${u.id}">停用</a></td>
						<td><a href="update?isInUse=0&id=${u.id}">恢复</a></td>
					</tr>	
					</c:forEach>			
				</table>
			</div>
		</div>
	<!--主体/-->
		  <div class="qingli" style="width:100%;height:400px;"></div>
		</c:if>
		
		<!--房屋管理<>-->
		<c:if test="${param.sort==5||empty  param.sort}">
			<div class="row ">
				<div class="col-md-12 ">
					<table border="1px " class="table table-hover ">
						<th id="fangwu">房屋管理</th>
						<tr>
							<td>序号</td>
							<td>房屋id</td>
							<td>房主</td>
							<td>房间类型）</td>
							<td>所属街道</td>
							<td>楼层信息</td>
							<td>价格</td>
							<td>更新时间</td>
							<td>主题</td>
							<td>坐标（经度/纬度）</td>
							<td>房屋状态：<select name="sort"
								onchange="location.href=this.options[this.selectedIndex].value;">
									<option value="list?houseSort=2#fangwu">全部</option>
									<option value="list?houseSort=1#fangwu"
										<c:if test="${param.houseSort==1}">selected="selected"</c:if>>正常
									</option>
									<option value="list?houseSort=0#fangwu"
										<c:if test="${param.houseSort==0}">selected="selected"</c:if>>违规</option>
							</select>

							</td>
						</tr>

						<c:forEach items="${houses}" var="h" varStatus="status">
							<tr>
								<td>${status.index + 1}</td>
								<td>${h.id}</td>
								<td>${h.user.name}</td>
								<td>${h.type.name }</td>
								<td>${h.street.name }</td>
								<td>${h.floor}</td>
								<td>${h.price}</td>
								<td><fmt:formatDate pattern="yyyy-MM-dd  hh:mm:ss"
										value="${h.updateTime }" /></td>
								<td>${h.topic }</td>
								<td>${h.longitude}/${h.latitude }</td>
								<td><c:if test="${h.state==0}">违规</c:if> <c:if
										test="${h.state==1}">正常</c:if></td>
								<td><a href="delete?sort=4&id=${h.id}" >删除</a></td>
							</tr>
						</c:forEach>
					</table>
				</div>
			</div>

			<!--主体/-->
			<div class="qingli" style="width: 100%; height: 400px;"></div>
		</c:if>
		
		
		<div class="qingli" style="width: 100%; height: 600px;"></div>
	</div>
</body>